package diaosidadui.oop03;

public class Phone {
    /*
    定义手机类，手机有品牌(brand),价格(price)和颜色(color)三个属性，有打电话call()和sendMessage()两个功能。

定义测试类，在主方法中创建对象，直接给对象的属性赋值。

调用对象的两个功能，打印效果如下：

     */
    private String brand;
    private double price;
    private String color;

    public Phone() {
    }

    public Phone(String brand, double price, String color) {
        this.brand = brand;
        this.price = price;
        this.color = color;
    }

    public void setBrand(String brand) {
        this.brand=brand;
    }

    public String getBrand() {
        return brand;
    }

    public void setPrice(double price) {
        this.price = price;
    }
    public double getPrice(){
        return price;
    }

    public void setColor(String color){
        this.color=color;
    }
    public String getColor(){
        return this.color;
    }
    public void call(String name) {
        System.out.println("给"+name+"打电话");
    }

    public void sendMessage(String txt) {
        System.out.println("给所有人发消息:"+txt);
    }

    @Override
    public String toString() {
        return "Phone{" +
                "brand='" + brand + '\'' +
                ", price=" + price +
                ", color='" + color + '\'' +
                '}';
    }
}
